
{php
	$parse_file=function($file,$line=0){
		if($file){
			$fullname = $file;
			return '<span class="simplified-info file-info dbclick-copy" title="'.$fullname.'">'.basename($file).'</span>'.($line?' line '.$line:'');
		}
		return '';
	};
	$parse_class=function($name,$simp=false){
		if($simp)return '<span class="simplified-info class-info dbclick-copy" title="\\'.$name.'">'.end(explode('\\', $name)).'</span>';
		return '<span class="simplified-info class-info">\\'.$name.'</span>';
	};
	$parse_args=function($args)use($parse_class,$parse_file,&$parse_args){
		if(!is_array($args)){
			$args=[$args];
		}
		$result=[];
		foreach($args as $key => $item){
			if(is_object($item)){
				$value=$parse_class(get_class($item),true);
			}elseif(is_array($item)){
				if(count($item)>3){
					$value='';
					$itemCount=0;
					foreach($item as $itemk=>$itemv){
						$item_k=strtolower($itemk);
						if($item_k=='user' or $item_k=='pass' or $item_k=='username' or $item_k=='password' or $item_k=='dbuser' or $item_k=='dbpass'){
							$valuei='[Private Info]';
						}elseif(is_array($itemv)){
							$valuei='[...]';
						}else{
							$valuei=$parse_args($itemv);
						}
						if(!is_int($itemk)){
							$valuei="'$itemk'=>".$valuei;
						}
						if($itemCount>=3){
							$value.=', ...';
							break;
						}elseif($itemCount===0){
							$value.=$valuei;
						}else{
							$value.=','.$valuei;
						}
						$itemCount++;
					}
				}else{
					$value=$parse_args($item);
				}
				$value='<span class="simplified-info array-info">['.$value.']</span>';
			}elseif(is_null($item)){
				$value='null';
			}elseif(is_bool($item)){
				$value=$item?'true':'false';
			}elseif(is_file($item) or is_dir($item)){
				$value="'".$parse_file($item)."'";
			}else{
				if(strlen($item) > 30){
					$value='<span class="simplified-info string-info" title="'.htmlentities($item).'">\''.htmlentities(substr($item, 0, 28)).'...\'</span>';
				}else{
					$value='<span class="simplified-info string-info">\''.htmlentities($item).'\'</span>';
				}
			}
			if($value)$result[]=is_int($key)?$value:"'".$key."'=>".$value;
		}
		return implode(',',$result);
	}
/}
<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<meta name="robots" content="noindex,nofollow" />
	<title>系统发生错误</title>
	{if !$debug}
	<style>
		body {
			color: #333;
			font-family: "Consolas", "Liberation Mono", "Courier", "Verdana", "Microsoft YaHei";
			font-size: 16px;
			margin: 0;
			padding: 20px;
			line-height: 1.2em;
			overflow: auto;
		}

		div,h1,h2,h3,span,a{
			box-sizing: border-box;
			overflow: hidden;
			line-height: 1.2em;
		}

		a {
			color: #999;
			cursor: pointer;
		}

		a:hover {
			text-decoration: underline;
		}

		h1 {
			margin: 0;
			padding: 0;
			font-size: 24px;
			font-weight: 500;
			color: #f55;
		}

		.copyright{
			margin-top: 20px;
			padding: 16px 0;
			border-top: 1px solid #eee;
		}
	</style>
	{else}
	<style>
		body {
			color: #333;
			font-family: "Consolas", "Liberation Mono", "Courier", "Verdana", "Microsoft YaHei";
			font-size: 16px;
			margin: 0;
			padding: 20px;
			line-height: 1.2em;
			overflow: auto;
		}

		div,h1,h2,h3,span,a{
			box-sizing: border-box;
			overflow: hidden;
			line-height: 1.2em;
		}

		a {
			color: #999;
			cursor: pointer;
		}

		a:hover {
			text-decoration: underline;
		}

		.dbclick-copy {
			user-select: none;
			cursor: default;
		}

		.error-info {
			color: #f55;
		}

		.file-info {
			color: #3a3;
		}

		.simplified-info.file-info{
			text-decoration: dotted underline;
		}

		.string-info {
			color: #666;
		}

		.array-info {
			color: #666;
		}

		.function-info {
			color: #27f;
		}

		.class-info {
			color: #27f;
		}

		.message {
			padding: 20px;
			border: 1px solid #ddd;
			font-size: 16px;
			border-radius: 8px;
		}

		.message h1 {
			margin: 0;
			padding: 0;
			font-size: 24px;
			font-weight: 500;
		}

		.message .thrown-file{
			margin-top: 10px;
			font-size: 18px;
		}

		.debug-datas {
			margin-top: 20px;
			border-radius: 8px;
			border: 1px solid #ddd;
		}

		.debug-datas-content {
			padding: 20px;
		}

		.debug-datas pre {
			margin: 0;
			padding: 0;
			font-size: 14px;
		}

		.debug-datas h2 {
			color: #f83;
			margin: 0;
			padding: 20px;
			font-size: 20px;
			font-weight: 500;
			border-bottom:solid 1px #eee;
			overflow:hidden;
		}

		.trace {
			margin-top: 20px;
			border-radius: 8px;
			border: 1px solid #ddd;
			font-size: 14px;
			overflow: hidden;
		}

		.trace h2 {
			color: #f83;
			margin: 0;
			padding: 20px;
			font-size: 20px;
			font-weight: 500;
			border-bottom:solid 1px #eee;
			overflow:hidden;
		}

		.trace ol li {
			padding: 3px;
			padding-left: 0;
			margin-left: 5px;
		}

		.included {
			margin-top: 20px;
			border-radius: 8px;
			border: 1px solid #ddd;
			font-size: 14px;
			overflow: hidden;
		}

		.included h2 {
			color: #f83;
			margin: 0;
			padding: 20px;
			font-size: 20px;
			font-weight: 500;
			border-bottom:solid 1px #eee;
			overflow:hidden;
		}

		.included ol li {
			padding: 3px;
			padding-left: 0;
			margin-left: 5px;
		}

        .vars {
			margin-top: 20px;
			border-radius: 8px;
			border: 1px solid #ddd;
			font-size: 14px;
			overflow: hidden;
		}

		.vars h2 {
			color: #f83;
			margin: 0;
			padding: 20px;
			font-size: 20px;
			font-weight: 500;
			border-bottom:solid 1px #eee;
			overflow:hidden;
		}

		.vars table{
			width: 100%;
			margin: 20px;
			background:#ddd;
			border:solid 1px #ddd;
			border-radius:8px;
			overflow:hidden;
			border-collapse:collapse;
			border-spacing:0;
			overflow: hidden;
		}

		.vars table > table{
			margin-top: 0;
		}

		.vars thead th{
			padding: 12px 10px;
			font-size: 18px;
			background:#ccc;
			text-align: left;
			vertical-align: top;
            font-weight: 600;
            white-space: nowrap;
		}

		.vars thead th small{
			font-weight: 400;
			display: inline-block;
			margin-left: 10px;
			color: #777;
		}

		.vars tbody th{
			width: 20%;
			padding: 8px;
			font-size: 16px;
			background:#fff;
			text-align: left;
			vertical-align: top;
            font-weight: 600;
            white-space: nowrap;
		}

		.vars tbody td{
			padding: 8px;
			font-size: 14px;
			background:#fff;
			word-break: break-all;
		}
		
		.vars tbody tr:nth-child(even) th,
		.vars tbody tr:nth-child(even) td{
			background:#eee;
		}

		.vars tbody tr:hover th,
		.vars tbody tr:hover td{
			background:#ddd!important;
		}

		.copyright{
			margin-top: 20px;
			padding: 16px 0;
			border-top: 1px solid #ddd;
		}
	</style>
	{/if}
</head>
<body>
	{if !$debug}
		<div class="message">
			<h1>{$message}</h1>
		</div>
	{else}
		<div class="message">
			<h1><span class="error-info">{$message}</span></h1>
			{if $file}
			<div class="thrown-file">
				in <span class="file-info dbclick-copy">{$file}</span>
				{if $line} line {$line}{/if}
			</div>
			{/if}
		</div>
		{if $data}
			<div class="debug-datas">
				<h2>Debug Datas</h2>
				<div class="debug-datas-content">
					<pre>{php echo print_r($data,true) /}</pre>
				</div>
			</div>
		{/if}
		<div class="trace">
			<h2>Call Stack</h2>
			<ol>
				{if $thrown}
					<li>in {php echo $parse_file($thrown['file'],$thrown['line'])/}</li>
				{/if}
				{foreach $trace as $value}
					{if $value and $value['function']}
						<li>
							at
							{if $value['class']}{php echo $parse_class($value['class'])/}<span class="class-info">-></span>{/if}<span class="function-info">{$value['function']}</span><span class="function-info">(</span>{php echo $parse_args($value['args'])/}<span class="function-info">)</span>
							in
							{php echo $parse_file($value['file'],$value['line'])/}
						</li>
					{/if}
				{/foreach}
			</ol>
		</div>
		<div class="included">
			<h2>Included Files</h2>
			<ol>
				{foreach $included as $file}
					<li>{$file}</li>
				{/foreach}
			</ol>
		</div>
		<div class="vars">
			<h2>Environment Variables</h2>
			{foreach $vars $vname $vdata}
				<table>
					<thead>
						<tr><th colspan="2">{$vname} Data {if !$vdata}<small>empty</small>{/if}</th></tr>
					</thead>
					<tbody>
						{foreach $vdata $var $val}
							<tr>
								<th>{$var}</th>
								<td>{if is_array($val)}{:print_r($val,true)}{else}{$val}{/if}</td>
							</tr>
						{/foreach}
					</tbody>
				</table>
			{/foreach}
		</div>
	{/if}
	<input type="text" id="copy-input" style="position:fixed;left:0;top:0;opacity:0;" value="">
	<div id="message" style="display:none;position:fixed;left:50%;top:50px;transform:translateX(-50%);padding:10px 12px;border-radius:5px;background:#f83;color:#fff;"></div>
	<script>
		document.querySelectorAll('.dbclick-copy').forEach(function(item){
			item.addEventListener('dblclick',function(){
				if(typeof navigator.clipboard!='undefined'){
					navigator.clipboard.writeText(text);
				}else{
					const input = document.getElementById('copy-input');
					input.value = this.title;
					input.focus();
					input.select();
					document.execCommand('copy',false,null);
					input.blur();
				}
				message('已复制到剪贴板');
			});
		});
		function message(message){
			const messageDiv = document.getElementById('message');
			messageDiv.innerText = message;
			messageDiv.style.display = 'block';
			clearTimeout(window.timer);
			window.timer = setTimeout(function(){
				messageDiv.style.display = 'none';
			}, 2000);
		}
	</script>
	<div class="copyright">
		轻量PHP框架 - <a title="XGPHP官方" href="http://xgphp.xg3.cn" target="_blank">XGPHP</a> V{php echo XG_VERSION;/} 版权所有 &copy; 2020-2025 讯高科技
	</div>
</body>
</html>